home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-02-16 | 2.7 KB | 108 lines | [TEXT/GEOL] |
- Item 9346392 16-Feb-90 07:38PST
-
- From: KEMINK1 Kemink, Joost
-
- To: BETA Beta, Edward Anuff,PRT
-
- cc: MACAPP.TECH$ MacApp Technical
-
- Sub: Re BackGr BMaps 2nd try
-
- Brett,
-
- When I read my AppleLinks this morning, I was surprised to see my reply to you.
- I sent your question instead of my reply. That happens when sending links after
- midnight I guess. Anyway, apologies to you and the other MacAppers that may
- have received that link (I removed it).
-
- Here is the link I intended to send.
-
- I prefer to use MacApp's idle mechanism. It is easy to understand and only a
- few things have to be done to get it up and running. Below I have included the
- source code for a counter that counts backwards and displays its value, nothing
- fancy. As long as you remember to keep the execution of your idle chunks
- relatively short, the user won't experience any user interface latency.
-
- You don't have to be afraid that your mouse 'freezes' while your idle task is
- executed, since mouse movement is handled by interrupts. These interrupts
- continue, even while you are execute your idle task.
-
- Add the following code to the Nothing example, add a field fIdler to
- TNothingApplication and change INothingApplication as shown. This should give
- you something to experiment with.
-
- TIdler = OBJECT(TEvtHandler)
- fToGo : INTEGER;
-
- PROCEDURE TIdler.IIdler(initialValue:INTEGER);
-
- PROCEDURE TIdler.Install;
- PROCEDURE TIdler.Remove;
-
- FUNCTION TIdler.DoIdle(phase:IdlePhase):BOOLEAN; OVERRIDE;
-
- FUNCTION TIdler.IsFinished:BOOLEAN;
- END;
-
- PROCEDURE TIdler.IIdler(initialValue:INTEGER);
- BEGIN
- SELF.IEvtHandler(NIL);
-
- SELF.fToGo:=initialValue;
- SELF.fIdleFreq:=0; { • Idle as often as possible }
- END;
-
- FUNCTION TIdler.DoIdle(phase:IdlePhase):BOOLEAN; OVERRIDE;
- BEGIN
- IF NOT SELF.IsFinished THEN
- BEGIN
- SELF.fToGo:=SELF.fToGo-1;
- {$IFC qDebug}
- Writeln('To Go: ',SELF.fToGo:1);
- {$ENDC qDebug}
- END;
- IF SELF.IsFinished THEN
- SELF.Remove;
- DoIdle:=FALSE;
- END;
-
- PROCEDURE TIdler.Install;
- BEGIN
- gApplication.InstallCoHandler(SELF,TRUE);
- END;
-
- PROCEDURE TIdler.Remove;
- BEGIN
- gApplication.InstallCoHandler(SELF,FALSE);
- END;
-
- FUNCTION TIdler.IsFinished:BOOLEAN;
- BEGIN
- IsFinished:=(SELF.fToGo<=0);
- END;
-
- PROCEDURE TNothingApplication.INothingApplication(
- itsMainFileType: OSType);
- VAR
- anIdler : TIdler;
- BEGIN
- IApplication(itsMainFileType);
-
- RegisterStdType('TDefaultView', kStdDefaultView);
- IF gDeadStripSuppression THEN
- IF Member(TObject(NIL), TDefaultView) THEN ;
-
- New(anIdler);
- FailNIL(anIdler);
- anIdler.IIdler(30000);
- SELF.fIdler:=anIdler;
- anIdler.Install;
- END;
-
- { ----- }
-
- Hope this helps,
-
- Joost Kemink
-
-